/*
 * Copyright (c) 2008, Xiong Yingfei, the University of Tokyo
 * All rights reserved.
 */
package ac.jp.u_tokyo.SyncLib.tests;

import static org.junit.Assert.*;

import java.io.File;
import java.io.IOException;

import org.antlr.runtime.ANTLRFileStream;
import org.antlr.runtime.ANTLRStringStream;
import org.antlr.runtime.BitSet;
import org.antlr.runtime.CommonTokenStream;
import org.antlr.runtime.IntStream;
import org.antlr.runtime.MismatchedTokenException;
import org.antlr.runtime.RecognitionException;
import org.antlr.runtime.TokenStream;
import org.junit.Test;

import ac.jp.u_tokyo.SyncLib.language2.LanguageLexer;
import ac.jp.u_tokyo.SyncLib.language2.LanguageParser;

public class Language2AcceptanceTest
{
	
	private class TestParser extends LanguageParser{

		public TestParser(TokenStream input)
		{
			super(input);
		}

		@Override
		public void emitErrorMessage(String s)
		{
			fail(s);
		}
		
		@Override
		protected void mismatch(IntStream input, int ttype, BitSet follow)
		  throws RecognitionException
		{
		  throw new MismatchedTokenException(ttype, input);
		}
	}

	final static String EJBFILENAME = "testfiles/ejb2.sync";
	final static String BASEPATH = "testfiles/";
	
	@Test
	public void testParsing() throws Exception {
		ANTLRFileStream input = new ANTLRFileStream(EJBFILENAME);
		LanguageLexer lexer = new LanguageLexer(input);
		lexer.setBasePath(BASEPATH);
		LanguageParser parser = new TestParser(new CommonTokenStream(lexer));
		parser.prog();
	}
}
